blob: c64fbdb0f1822e66c451e81f25f72233eadd094d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
---
import translate from '$i18n/translate';
import tPage from '$i18n/translations/pages/news';
import Page from '$layouts/Page.astro';
import getLocaleFromPath from '$lib/getLocaleFromPath';
import localeStaticPaths from '$lib/localeStaticPaths';
import { getCollection } from 'astro:content';
import NewsPreviewLink from '$components/NewsPreviewLink.astro';
import { isNewsItemInLocale } from '$lib/newsUtils';
const allNews = await getCollection('news');
const locale = getLocaleFromPath(Astro.url.pathname);
const allNewsInLocale = allNews.filter((item) => isNewsItemInLocale(item, locale));
const t = translate(locale);
export async function getStaticPaths() {
return localeStaticPaths;
}
---
<Page title={t(tPage, { key: 'title' })}>
<section>
<h1>{t(tPage, { key: 'title' })}</h1>
<div class="news-index">
{
allNewsInLocale.length > 0 ? (
allNewsInLocale.map((item) => <NewsPreviewLink newsItem={item} />)
) : (
<p>{t(tPage, { key: 'no-news' })}</p>
)
}
</div>
</section>
</Page>
|